package com.liuc.practice.ipersistent.sqlSession;

import com.liuc.practice.ipersistent.config.ConfigurationBuilder;
import com.liuc.practice.ipersistent.pojo.Configuration;
import com.liuc.practice.ipersistent.sqlSession.impl.DefaultSqlSessionFactory;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * 该类用于构建 SqlSessionFactory
 *
 * @Author Liu Chang
 * @Date 2020/12/13 6:47 上午
 */
public class SqlSessionFactoryBuilder {

    private Configuration configuration;

    public SqlSessionFactoryBuilder(InputStream inputStream) throws PropertyVetoException,DocumentException {
        ConfigurationBuilder builder = new ConfigurationBuilder();
        this.configuration = builder.build(inputStream);
    }

    public DefaultSqlSessionFactory builder() {
        return new DefaultSqlSessionFactory(configuration);
    }
}
